﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WCFInvest.Security.ConsoleClient
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void GetServiceButton_Click(object sender, EventArgs e)
        {
            using (ConsoleClient.SampleClient proxy = new ConsoleClient.SampleClient())
            {
                proxy.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential() { 
                    UserName = UserNameTextBox.Text,
                    Password = PasswordTextBox.Text,
                    Domain =DomainTextBox.Text
                };
                try
                {
                    ResultTextBox.Text = proxy.GetMemberCode() + "\r\n";
                }
                catch (Exception error)
                {
                    ResultTextBox.Text += " GetMemberCode:" + error.Message + "\r\n";
                }
                try
                {
                    ResultTextBox.Text += proxy.GetPublicCode() + "\r\n";
                }
                catch (Exception error)
                {
                    ResultTextBox.Text += " GetPublicCode:" + error.Message + "\r\n";
                }
                try
                {
                    ResultTextBox.Text += proxy.GetSecretCode() + "\r\n";
                }
                catch (Exception error)
                {
                    ResultTextBox.Text += " GetSecretCode:" + error.Message + "\r\n";
                }
            }
        }

        private void CloseButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void MainForm_Load(object sender, EventArgs e)
        { 

        }
         
    }
}
